﻿using Newtonsoft.Json;
using System;
using System.IO;
using System.Windows.Forms;
using System.Xml;

namespace Ldt.WindowsFormsApp.ToolsForm
{
    /// <summary>
    /// 案件要素转doc测试窗口
    /// </summary>
    public partial class FormElementToDoc : Form
    {
        public FormElementToDoc()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 选择文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSelectFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "XML文件(*.xml)|*.xml";
            fileDialog.Multiselect = false;
            if (fileDialog.ShowDialog()==DialogResult.OK)
            {
                textBoxConfigFilePath.Text = fileDialog.FileName;
            }
            
        }

        /// <summary>
        /// 进行数据校验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonVerifyData_Click(object sender, EventArgs e)
        {
            //richTextBoxLog.Clear();
            ////要素数据
            //if (!string.IsNullOrWhiteSpace(richTextBoxElementSource.Text))
            //{
            //    //richTextBoxElementSource.Text;
            //    XmlDocument xmldocument = new XmlDocument();
            //    xmldocument.LoadXml(richTextBoxElementSource.Text);
            //    //textBoxConfigFilePath.Text
            //    if (!string.IsNullOrWhiteSpace(textBoxConfigFilePath.Text))
            //    {
            //        string content = File.ReadAllText(textBoxConfigFilePath.Text);
            //        //转换结果数据
            //        //日志输出
            //        //richTextBoxLog.Text;
            //        ElementToTableConfig(xmldocument, content);
            //    }
            //    else 
            //    {
            //        MessageBox.Show("校验配置文件路径不能为空！");
            //    }

            //}
            //else 
            //{
            //    MessageBox.Show("要素数据不能为空！");
            //}
           
        }

        ///// <summary>
        ///// 转doc配置数据
        ///// </summary>
        ///// <param name="xmldoc">xmldoc</param>
        ///// <param name="xmldoc">xmldoc</param>
        ///// <returns></returns>
        //public string ElementToTableConfig(XmlDocument xmldoc,string toContent)
        //{
        //    if (string.IsNullOrEmpty(toContent))
        //    {
        //        richTextBoxLog.AppendText("转实体配置为空" + System.Environment.NewLine);
        //    }
        //    else
        //    {
        //        DataConverTable dataConverTable = new DataConverTable(toContent);
        //        dataConverTable.XmlNodeRoot = xmldoc.SelectSingleNode("/*").ParentNode;
        //        //string datamessage = dataConverTable.SaveDictabel(xmldoc.SelectSingleNode("/*").ParentNode, dynamicDataStores);
        //        dataConverTable.SetDicTabel("",null, xmldoc.SelectSingleNode("/*").ParentNode, "",(a)=> { richTextBoxLog.AppendText(a+System.Environment.NewLine); },null);
        //        dataConverTable. SupplementCaseManage();
        //        richTextBoxResult.Text = JsonConvert.SerializeObject(dataConverTable.DicTable);
        //    }
        //    return "";
        //}

    }
}
